package com.carl.zlds.tool.util;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JsonUtil {
    private static final Logger log = LoggerFactory.getLogger(com.carl.zlds.tool.util.JsonUtil.class);
    private static ObjectMapper objectMapper = new ObjectMapper();

    public JsonUtil() {
    }

    public static Object fromJson(String string, Class clazz) {
        try {
            return objectMapper.readValue(string, clazz);
        } catch (IOException var3) {
            var3.printStackTrace();
            return null;
        }
    }

    public static Object fromJson(String string, TypeReference typeReference) {
        try {
            return objectMapper.readValue(string, typeReference);
        } catch (IOException var3) {
            var3.printStackTrace();
            return null;
        }
    }

    public static String toJson(Object object) {
        try {
            return objectMapper.writeValueAsString(object);
        } catch (JsonProcessingException var2) {
            var2.printStackTrace();
            return null;
        }
    }
}
